package com.lhb.ojuserservice.controller.inner;

import com.lhb.ojmodel.model.entity.User;
import com.lhb.ojserviceclient.feignclient.UserFeignClient;
import com.lhb.ojuserservice.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/*
* 仅限服务内部进行调用
* UserFeignClient的实现类
* */
@RestController
@RequestMapping("/inner")
public class UserInnerController implements UserFeignClient {
    @Resource
    private UserService userService;

    /*
    * 获取用户列表
    * */
    @Override
    @GetMapping("/get/idList")
    public List<User> listByIds(@RequestParam("idList") Collection<Long> idList) {
       return userService.listByIds(idList);
    }

    /*
    * 获取用户信息
    * */
    @Override
    @GetMapping("/get/id")
    public User getById(@RequestParam("id") Long id) {
        return userService.getById(id);
    }
}
